Xbasic

DELETE_RECORD Method

Syntax

Validation object as P = <Tbl>.delete_record('var')

Arguments

var

A dot variable with the field values from the specified table.

Description

Allows for data to be deleted via Xbasic, when using a Form or Browse. Returns a dot variable that is the validation object.

The example below shows how to use the .delete_record() method:

'DIM a dot variable with properties that match the fieldnames you want to delete
dim r as p
r.firstname = ""
r.company = "alpha"
v = t.delete_record(r)
?v.has_errors
= .T.
?v.error.size()
= 2

?v.Format("$(field) = $(error)"+crlf())
= CUSTOMER1->COMPANY = company can't be alpha
CUSTOMER1->LASTNAME = Field is required: LASTNAME

As the example shows, a dot variable is created with properties for all of the fields that you want to delete. In the above example, we specify the 'firstname' and 'company' fields in the customer table. Once the dot variable has been created, the <Tbl>.delete_record() method is called. This method takes as its argument the dot variable with the field values.

The method returns a dot variable. The dot variable has an 'has_errors' property which lets you know if the method succeeded or not. If not, then the errors are returned in an array called 'errors' which is a sub-property of the dot variable.

See Also